{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 10.1 \u6784\u5efa\u4e00\u4e2a\u6a21\u5757\u7684\u5c42\u7ea7\u5305\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u95ee\u9898\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f60\u60f3\u5c06\u4f60\u7684\u4ee3\u7801\u7ec4\u7ec7\u6210\u7531\u5f88\u591a\u5206\u5c42\u6a21\u5757\u6784\u6210\u7684\u5305\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u89e3\u51b3\u65b9\u6848\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5c01\u88c5\u6210\u5305\u662f\u5f88\u7b80\u5355\u7684\u3002\u5728\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7ec4\u7ec7\u4f60\u7684\u4ee3\u7801\uff0c\u5e76\u786e\u4fdd\u6bcf\u4e2a\u76ee\u5f55\u90fd\u5b9a\u4e49\u4e86\u4e00\u4e2a__init__.py\u6587\u4ef6\u3002\n\u4f8b\u5982\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "graphics/\n    __init__.py\n    primitive/\n        __init__.py\n        line.py\n        fill.py\n        text.py\n    formats/\n        __init__.py\n        png.py\n        jpg.py"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e00\u65e6\u4f60\u505a\u5230\u4e86\u8fd9\u4e00\u70b9\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u6267\u884c\u5404\u79cdimport\u8bed\u53e5\uff0c\u5982\u4e0b\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import graphics.primitive.line\nfrom graphics.primitive import line\nimport graphics.formats.jpg as jpg"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u8ba8\u8bba\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5b9a\u4e49\u6a21\u5757\u7684\u5c42\u6b21\u7ed3\u6784\u5c31\u50cf\u5728\u6587\u4ef6\u7cfb\u7edf\u4e0a\u5efa\u7acb\u76ee\u5f55\u7ed3\u6784\u4e00\u6837\u5bb9\u6613\u3002\n\u6587\u4ef6__init__.py\u7684\u76ee\u7684\u662f\u8981\u5305\u542b\u4e0d\u540c\u8fd0\u884c\u7ea7\u522b\u7684\u5305\u7684\u53ef\u9009\u7684\u521d\u59cb\u5316\u4ee3\u7801\u3002\n\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u4f60\u6267\u884c\u4e86\u8bed\u53e5import graphics\uff0c \u6587\u4ef6graphics/__init__.py\u5c06\u88ab\u5bfc\u5165,\u5efa\u7acbgraphics\u547d\u540d\u7a7a\u95f4\u7684\u5185\u5bb9\u3002\u50cfimport graphics.format.jpg\u8fd9\u6837\u5bfc\u5165\uff0c\u6587\u4ef6graphics/__init__.py\u548c\u6587\u4ef6graphics/formats/__init__.py\u5c06\u5728\u6587\u4ef6graphics/formats/jpg.py\u5bfc\u5165\u4e4b\u524d\u5bfc\u5165\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u7edd\u5927\u90e8\u5206\u65f6\u5019\u8ba9__init__.py\u7a7a\u7740\u5c31\u597d\u3002\u4f46\u662f\u6709\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u5305\u542b\u4ee3\u7801\u3002\n\u4e3e\u4e2a\u4f8b\u5b50\uff0c__init__.py\u80fd\u591f\u7528\u6765\u81ea\u52a8\u52a0\u8f7d\u5b50\u6a21\u5757:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# graphics/formats/__init__.py\nfrom . import jpg\nfrom . import png"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u50cf\u8fd9\u6837\u4e00\u4e2a\u6587\u4ef6,\u7528\u6237\u53ef\u4ee5\u4ec5\u4ec5\u901a\u8fc7import grahpics.formats\u6765\u4ee3\u66ffimport graphics.formats.jpg\u4ee5\u53caimport graphics.formats.png\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__init__.py\u7684\u5176\u4ed6\u5e38\u7528\u7528\u6cd5\u5305\u62ec\u5c06\u591a\u4e2a\u6587\u4ef6\u5408\u5e76\u5230\u4e00\u4e2a\u903b\u8f91\u547d\u540d\u7a7a\u95f4\uff0c\u8fd9\u5c06\u572810.4\u5c0f\u8282\u8ba8\u8bba\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u654f\u9510\u7684\u7a0b\u5e8f\u5458\u4f1a\u53d1\u73b0\uff0c\u5373\u4f7f\u6ca1\u6709__init__.py\u6587\u4ef6\u5b58\u5728\uff0cpython\u4ecd\u7136\u4f1a\u5bfc\u5165\u5305\u3002\u5982\u679c\u4f60\u6ca1\u6709\u5b9a\u4e49__init__.py\u65f6\uff0c\u5b9e\u9645\u4e0a\u521b\u5efa\u4e86\u4e00\u4e2a\u6240\u8c13\u7684\u201c\u547d\u540d\u7a7a\u95f4\u5305\u201d\uff0c\u8fd9\u5c06\u572810.5\u5c0f\u8282\u8ba8\u8bba\u3002\u4e07\u7269\u5e73\u7b49\uff0c\u5982\u679c\u4f60\u7740\u624b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5305\u7684\u8bdd\uff0c\u5305\u542b\u4e00\u4e2a__init__.py\u6587\u4ef6\u5427\u3002"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "base_numbering": 1,
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": true,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": true
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}